﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using DSPL.Contracts;
using DSPL.Contracts.Common;

namespace DSPL.DataAccess.MasterData
{
    public class GetHelp
    {

        private DatabaseAccess _databaseAccess;


        public GetHelp()
        {
            _databaseAccess = DatabaseAccess.Instance;
        }
        public DataTable HelpArea()
        {
            // "Select AreaCode,AreaName From fArea Order By AreaCode";
            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "AreaPk" });
            columnList.Add(new ColumnWithValue() { ColumnName = "AreaCode" });
            columnList.Add(new ColumnWithValue() { ColumnName = "AreaName" });
            List<ColumnWithValue> orderList = new List<ColumnWithValue>();
            orderList.Add(new ColumnWithValue() { ColumnName = "AreaCode" });
           
            Query query = new Query() { TableName ="fArea", QType = QueryType.SELECT,ColValues=columnList.ToArray(),OrderbyClause=orderList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));

        }

        /// <summary>
        /// To display the Bank details
        /// </summary>
        /// <returns></returns>
        public DataTable HelpBank()
        {
            string sql = "Select BankPk,BankCode,bankname From Fbank ORDER BY BankCode DESC";            
            Query query = new Query() { QueryString = sql, QType = QueryType.SELECTOTHER };
            return (_databaseAccess.ExcecuteSelect(query));

        }


        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public DataTable HelpAccCashBank() 
        {

            //string sql = "Select distinct a.AccCode,a.AccDesc From fGlfAcc a, fUsrCosDet b " +
            //         " Where a.CostCode=b.CostCode And b.UserId=@LoggedInUser And (a.AccCat=@accountCat1 Or a.AccCat=@accountCat2) and a.ConAcc<>@controlAccount order by AccCode";

            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "fGlfAcc.AccCode" });
            columnList.Add(new ColumnWithValue() { ColumnName = "fGlfAcc.AccDesc" });

            List<ColumnWithValue> joinStructure = new List<ColumnWithValue>();
            joinStructure.Add(new ColumnWithValue { FromTable = "fGlfAcc", FromColumn = "CostPk", ToTable = "fUsrCosDet", ToColumn = "CostPk", JoinType = QJoinType.INNERJOIN });

            List<ColumnWithValue> whereClause = new List<ColumnWithValue>();
            whereClause.Add(new ColumnWithValue { ColumnName = "fUsrCosDet.UserId", Level = 0, ColumnValue = GlobalVariables.LoggedInUser, Comparison = QComparison.EQUALS });
            whereClause.Add(new ColumnWithValue { ColumnName = "fGlfAcc.AccCat", Level = 1, ColumnValue = 2, ColumnConnector = QLogicOperator.AND, Comparison = QComparison.EQUALS });
            whereClause.Add(new ColumnWithValue { ColumnName = "fGlfAcc.AccCat", Level = 1, ColumnValue = 4, ColumnConnector = QLogicOperator.OR, Comparison = QComparison.EQUALS });
            whereClause.Add(new ColumnWithValue { ColumnName = "fGlfAcc.ConAcc", Level = 0, ColumnValue = "Y", ColumnConnector = QLogicOperator.AND, Comparison = QComparison.NOTEQUAL });

            List<ColumnWithValue> orderList = new List<ColumnWithValue>();
            orderList.Add(new ColumnWithValue() { ColumnName = "fGlfAcc.AccCode" });

            Query query = new Query() { ColValues = columnList.ToArray(), QType = QueryType.SELECTDISTINCT, TableName = "fGlfAcc", JoinStructure = joinStructure.ToArray(), WhereClause = whereClause.ToArray(), OrderbyClause = orderList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query, true));
        }

        /// <summary>
        /// To display account details
        /// </summary>
        /// <returns></returns>
        public DataTable HelpAccAlo()
        {
            //Select ConAccPk,AccCode,AccDesc From fConAcc
            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "ConAccPk" });
            columnList.Add(new ColumnWithValue() { ColumnName = "AccCode" });
            columnList.Add(new ColumnWithValue() { ColumnName = "AccDesc" });
            Query query = new Query() { TableName =  "fConAcc" , QType = QueryType.SELECT, ColValues = columnList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));

        }

        /// <summary>
        /// To display account details
        /// </summary>
        /// <returns></returns>

        public DataTable HelpAccCode()
        {
            // string sql = "Select ConAccPk,AccCode,AccDesc From fConAcc Order By AccCode";

            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "ConAccPk" });
            columnList.Add(new ColumnWithValue() { ColumnName = "AccCode" });
            columnList.Add(new ColumnWithValue() { ColumnName = "AccDesc" });
            List<ColumnWithValue> orderList = new List<ColumnWithValue>();
            orderList.Add(new ColumnWithValue() { ColumnName = "AccCode" });
            Query query = new Query() { TableName =  "fConAcc" , QType = QueryType.SELECT, ColValues = columnList.ToArray(), OrderbyClause = orderList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));
        }

        /// <summary>
        /// To display account details
        /// </summary>
        /// <returns></returns>

        public DataTable HelpAccounts()
        {
            // Select distinct a.AccCode,a.AccDesc From fGlfAcc a, fUsrCosDet b Where a.CostCode=b.CostCode and ;
            // b.UserId='&cUser' ORDER BY a.AccCode
            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "fGlfAcc.AccCode" });
            columnList.Add(new ColumnWithValue() { ColumnName = "fGlfAcc.AccDesc" });
            List<ColumnWithValue> orderList = new List<ColumnWithValue>();
            orderList.Add(new ColumnWithValue() { ColumnName = "fGlfAcc.AccCode" });

            List<ColumnWithValue> whereList = new List<ColumnWithValue>();
            whereList.Add(new ColumnWithValue() { ColumnName = "fUsrCosDet.UserId", Comparison = QComparison.EQUALS, ColumnValue = GlobalVariables.LoggedInUser });

            List<ColumnWithValue> joinList = new List<ColumnWithValue>();
            joinList.Add(new ColumnWithValue { FromTable = "fGlfAcc", ToTable = "fUsrCosDet", FromColumn = "CostPk", ToColumn = "CostPk", JoinType = QJoinType.INNERJOIN, Comparison = QComparison.EQUALS });
            Query query = new Query() { TableName =  "fGlfAcc" , QType = QueryType.SELECTDISTINCT, ColValues = columnList.ToArray(), OrderbyClause = orderList.ToArray(), WhereClause = whereList.ToArray(), JoinStructure = joinList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));

        }

        /// <summary>
        /// Get Type  details
        /// </summary>
        /// <returns></returns>
        public DataTable HelpType()
        {
            // Select TypePk,TypeCode,TypeName From fType ORDER BY TypeCode

            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "TypePk" });
            columnList.Add(new ColumnWithValue() { ColumnName = "TypeCode" });
            columnList.Add(new ColumnWithValue() { ColumnName = "TypeName" });
            List<ColumnWithValue> orderList = new List<ColumnWithValue>();
            orderList.Add(new ColumnWithValue() { ColumnName = "TypeCode" });
            Query query = new Query() { TableName =  "fType" , QType = QueryType.SELECT, ColValues = columnList.ToArray(), OrderbyClause = orderList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));

        }

        /// <summary>
        /// Get Price Level details
        /// </summary>
        /// <returns></returns>
        public DataTable HelpPriLvl()
        {
            string sqlPriceLevel = "Select a.PrilCode,a.PrilName from fPriLvl a Inner join fCurrency b ON a.CurPk=b.CurPk WHERE b.CurCode =@curCode order by a.PrilCode";

            var parametersPriceLevel = new List<Parameter>
                                 {
                                     new Parameter{ParamName="@curCode",ParamValue=GlobalVariables.BaseCurrency},
                                 };

            Query query = new Query() { QueryString = sqlPriceLevel, QType = QueryType.SELECTOTHER, ParameterList = parametersPriceLevel.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query,true));

        }

        /// <summary>
        /// To display Account Petty Cash
        /// </summary>
        /// <returns></returns>
        public DataTable HelpAccPettyCash()
        {
            // Select a.AccCode,a.AccDesc From fGlfAcc a, fUsrCosDet b Where a.CostCode=b.CostCode and 
            //b.UserId='&cUser' And a.AccCat='3' ORDER BY a.AccCode

            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "fGlfAcc.AccCode" });
            columnList.Add(new ColumnWithValue() { ColumnName = "fGlfAcc.AccDesc" });
            List<ColumnWithValue> orderList = new List<ColumnWithValue>();
            orderList.Add(new ColumnWithValue() { ColumnName = "fGlfAcc.AccCode" });

            List<ColumnWithValue> whereList = new List<ColumnWithValue>();
            whereList.Add(new ColumnWithValue() { ColumnName = "fUsrCosDet.UserId", Comparison = QComparison.EQUALS, ColumnValue = GlobalVariables.LoggedInUser });
            whereList.Add(new ColumnWithValue() { ColumnName = "fGlfAcc.AccCat", Comparison = QComparison.EQUALS, ColumnValue = '3' });

            List<ColumnWithValue> joinList = new List<ColumnWithValue>();
            joinList.Add(new ColumnWithValue { FromTable = "fGlfAcc", ToTable = "fUsrCosDet", FromColumn = "CostPk", ToColumn = "CostPk", JoinType = QJoinType.INNERJOIN, Comparison = QComparison.EQUALS });
            Query query = new Query() { TableName =  "fGlfAcc", QType = QueryType.SELECT, ColValues = columnList.ToArray(), OrderbyClause = orderList.ToArray(), WhereClause = whereList.ToArray(), JoinStructure = joinList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));
        }

        /// <summary>
        /// To display Account Type 2 -Cash In Hand
        /// </summary>
        /// <returns></returns>
        public DataTable HelpAccType2()
        {
            // Select a.AccCode,a.AccDesc From fGlfAcc a, fUsrCosDet b Where a.CostCode=b.CostCode and 
            // b.UserId='&cUser' And a.AccCat='2' ORDER BY AccCode

            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "fGlfAcc.AccCode" });
            columnList.Add(new ColumnWithValue() { ColumnName = "fGlfAcc.AccDesc" });
            List<ColumnWithValue> orderList = new List<ColumnWithValue>();
            orderList.Add(new ColumnWithValue() { ColumnName = "fGlfAcc.AccCode" });

            List<ColumnWithValue> whereList = new List<ColumnWithValue>();
            whereList.Add(new ColumnWithValue() { ColumnName = "fUsrCosDet.UserId", Comparison = QComparison.EQUALS, ColumnValue = GlobalVariables.LoggedInUser });
            whereList.Add(new ColumnWithValue() { ColumnName = "fGlfAcc.AccCat", Comparison = QComparison.EQUALS, ColumnValue = '2' });

            List<ColumnWithValue> joinList = new List<ColumnWithValue>();
            joinList.Add(new ColumnWithValue { FromTable = "fGlfAcc", ToTable = "fUsrCosDet", FromColumn = "CostPk", ToColumn = "CostPk", JoinType = QJoinType.INNERJOIN, Comparison = QComparison.EQUALS });
            Query query = new Query() { TableName =  "fGlfAcc" , QType = QueryType.SELECT, ColValues = columnList.ToArray(), OrderbyClause = orderList.ToArray(), WhereClause = whereList.ToArray(), JoinStructure = joinList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));
        }

        /// <summary>
        /// To display Account Type 4 -Cash In Hand
        /// </summary>
        /// <returns></returns>
        public DataTable HelpAccType4()
        {
            //Select a.AccCode,a.AccDesc From fGlfAcc a, fUsrCosDet b Where a.CostCode=b.CostCode 
            // and b.UserId='&cUser' And a.AccCat='4' ORDER BY a.AccCode

            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "fGlfAcc.AccCode" });
            columnList.Add(new ColumnWithValue() { ColumnName = "fGlfAcc.AccDesc" });
            List<ColumnWithValue> orderList = new List<ColumnWithValue>();
            orderList.Add(new ColumnWithValue() { ColumnName = "fGlfAcc.AccCode" });

            List<ColumnWithValue> whereList = new List<ColumnWithValue>();
            whereList.Add(new ColumnWithValue() { ColumnName = "fUsrCosDet.UserId", Comparison = QComparison.EQUALS, ColumnValue = GlobalVariables.LoggedInUser });
            whereList.Add(new ColumnWithValue() { ColumnName = "fGlfAcc.AccCat", Comparison = QComparison.EQUALS, ColumnValue = '4' });

            List<ColumnWithValue> joinList = new List<ColumnWithValue>();
            joinList.Add(new ColumnWithValue { FromTable = "fGlfAcc", ToTable = "fUsrCosDet", FromColumn = "CostPk", ToColumn = "CostPk", JoinType = QJoinType.INNERJOIN, Comparison = QComparison.EQUALS });
            Query query = new Query() { TableName = "fGlfAcc", QType = QueryType.SELECT, ColValues = columnList.ToArray(), OrderbyClause = orderList.ToArray(), WhereClause = whereList.ToArray(), JoinStructure = joinList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));

        }

        /// <summary>
       /// Get all the account details
       /// </summary>
       /// <returns></returns>
        public DataTable HelpAllAccounts()
        {
            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "AccCode" });
            columnList.Add(new ColumnWithValue() { ColumnName = "AccDesc" });
            List<ColumnWithValue> orderList = new List<ColumnWithValue>();
            orderList.Add(new ColumnWithValue() { ColumnName = "AccCode" });
            Query query = new Query() { TableName = "fGlfAcc", QType = QueryType.SELECT, ColValues = columnList.ToArray(), OrderbyClause = orderList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));
            
        }

        /// <summary>
        /// Get all the account details
        /// </summary>
        /// <returns></returns>
        public DataTable HelpAuthority()
        {
            //Select AthCode,AthName From fAutBud ORDER BY AthCode
            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "AthCode" });
            columnList.Add(new ColumnWithValue() { ColumnName = "AthName" });
            List<ColumnWithValue> orderList = new List<ColumnWithValue>();
            orderList.Add(new ColumnWithValue() { ColumnName = "AthCode" });
            Query query = new Query() { TableName = "fAutBud", QType = QueryType.SELECT, ColValues = columnList.ToArray(), OrderbyClause = orderList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));
           
        }

        /// <summary>
       /// Get Bin Location details
       /// </summary>
       /// <returns></returns>
        public DataTable HelpBinLoc()
        {
            //Select BinCode,BinName,LocCode From fBinLoc ORDER BY BinCode 
            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "BinCode" });
            columnList.Add(new ColumnWithValue() { ColumnName = "BinName" });
            columnList.Add(new ColumnWithValue() { ColumnName = "LocCode" });
            List<ColumnWithValue> orderList = new List<ColumnWithValue>();
            orderList.Add(new ColumnWithValue() { ColumnName = "BinCode" });
            Query query = new Query() { TableName = "fBinLoc", QType = QueryType.SELECT, ColValues = columnList.ToArray(), OrderbyClause = orderList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));
        }

         /// <summary>
       /// Get card type details
       /// </summary>
       /// <returns></returns>
        public DataTable HelpCardType()
        {

            //Select CrdTypCode,CrdTypName From fCardType ORDER BY CrdTypCode
            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "CrdTypCode" });
            columnList.Add(new ColumnWithValue() { ColumnName = "CrdTypName" });
           
            List<ColumnWithValue> orderList = new List<ColumnWithValue>();
            orderList.Add(new ColumnWithValue() { ColumnName = "CrdTypCode" });
            Query query = new Query() { TableName = "fCardType", QType = QueryType.SELECT, ColValues = columnList.ToArray(), OrderbyClause = orderList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));
        }

         /// <summary>
       /// Get cash accounts details
       /// </summary>
       /// <returns></returns>
        public DataTable HelpCashBookAccounts()
        {
            // Select distinct a.AccCode,a.AccDesc From fGlfAcc a, fUsrCosDet b Where a.CostCode=b.CostCode and b.UserId='&cUser'
            // ORDER BY a.AccCode
            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "fGlfAcc.AccCode" });
            columnList.Add(new ColumnWithValue() { ColumnName = "fGlfAcc.AccDesc" });
            List<ColumnWithValue> orderList = new List<ColumnWithValue>();
            orderList.Add(new ColumnWithValue() { ColumnName = "fGlfAcc.AccCode" });

            List<ColumnWithValue> whereList = new List<ColumnWithValue>();
            whereList.Add(new ColumnWithValue() { ColumnName = "fUsrCosDet.UserId", Comparison = QComparison.EQUALS, ColumnValue = GlobalVariables.LoggedInUser });
           
            List<ColumnWithValue> joinList = new List<ColumnWithValue>();
            joinList.Add(new ColumnWithValue { FromTable = "fGlfAcc", ToTable = "fUsrCosDet", FromColumn = "CostCode", ToColumn = "CostCode", JoinType = QJoinType.INNERJOIN, Comparison = QComparison.EQUALS });
            Query query = new Query() { TableName = "fGlfAcc", QType = QueryType.SELECTDISTINCT , ColValues = columnList.ToArray(), OrderbyClause = orderList.ToArray(), WhereClause = whereList.ToArray(), JoinStructure = joinList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));

        }

        /// <summary>
       /// Get Stock In Hand account details
       /// </summary>
       /// <returns></returns>
        public DataTable HelpStkInHandAcc() // need to check
        {
            //Select a.AccCode,a.AccDesc From fGlfAcc a,fGlfSc b where  a.AccSortPk = b.AccSortPk AND  b.AccTyp='B' and a.AccCat=1 and a.ConAcc='Y'  ORDER BY a.AccCode
           

            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "fGlfAcc.AccCode" });
            columnList.Add(new ColumnWithValue() { ColumnName = "fGlfAcc.AccDesc" });
            List<ColumnWithValue> orderList = new List<ColumnWithValue>();
            orderList.Add(new ColumnWithValue() { ColumnName = "fGlfAcc.AccCode" });

            List<ColumnWithValue> whereList = new List<ColumnWithValue>();
            whereList.Add(new ColumnWithValue() { ColumnName = "fGlfSc.AccTyp", Comparison = QComparison.EQUALS, ColumnValue = "B", ColumnConnector = QLogicOperator.AND });
            whereList.Add(new ColumnWithValue() { ColumnName = "fGlfAcc.AccCat", Comparison = QComparison.EQUALS, ColumnValue = 1, ColumnConnector = QLogicOperator.AND });
            whereList.Add(new ColumnWithValue() { ColumnName = "fGlfAcc.ConAcc", Comparison = QComparison.EQUALS, ColumnValue = "Y" });

            List<ColumnWithValue> joinList = new List<ColumnWithValue>();
            joinList.Add(new ColumnWithValue { FromTable = "fGlfAcc", ToTable = "fGlfSc", FromColumn = "AccSortPk", ToColumn = "AccSortPk", JoinType = QJoinType.INNERJOIN, Comparison = QComparison.EQUALS });

            Query query = new Query() { TableName = "fGlfAcc ", QType = QueryType.SELECT, ColValues = columnList.ToArray(), OrderbyClause = orderList.ToArray(), WhereClause = whereList.ToArray(), JoinStructure = joinList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));
        }

        /// <summary>
       /// Get cash accounts details
       /// </summary>
       /// <returns></returns>
        public DataTable HelpCashFlowCode()
        {
            // Select Cfseq,cfcode,cfname From fcashflow ORDER BY Cfseq 
            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "Cfseq" });
            columnList.Add(new ColumnWithValue() { ColumnName = "cfcode" });
            columnList.Add(new ColumnWithValue() { ColumnName = "cfname" });

            List<ColumnWithValue> orderList = new List<ColumnWithValue>();
            orderList.Add(new ColumnWithValue() { ColumnName = "Cfseq" });
            Query query = new Query() { TableName = "fcashflow", QType = QueryType.SELECT, ColValues = columnList.ToArray(), OrderbyClause = orderList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));

        }

        /// <summary>
       /// Get cheque details
       /// </summary>
       /// <returns></returns>
        public DataTable HelpCheque()
        {
            // SELECT a.chqno,a.RefNo,a.totalamt,a.cusbank,a.DebCode,a.Remarks,b.DebName FROM fpChqHed a,
            // fDebtor b  where a.DebCode=b.DebCode ORDER BY a.ChqNo desc
            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "fpChqHed.chqno"});
            columnList.Add(new ColumnWithValue() { ColumnName = "fpChqHed.RefNo"});
            columnList.Add(new ColumnWithValue() { ColumnName = "fpChqHed.totalamt"});
            columnList.Add(new ColumnWithValue() { ColumnName = "fpChqHed.cusbank"});
            columnList.Add(new ColumnWithValue() { ColumnName = "fpChqHed.DebCode"});
            columnList.Add(new ColumnWithValue() { ColumnName = "fpChqHed.Remarks"});
            columnList.Add(new ColumnWithValue() { ColumnName = "fDebtor.DebName"});

            List<ColumnWithValue> orderList = new List<ColumnWithValue>();
            orderList.Add(new ColumnWithValue() { ColumnName = "fpChqHed.ChqNo" ,OrderBy=QOrderby.DESCENDING});
                      
            List<ColumnWithValue> joinList = new List<ColumnWithValue>();
            joinList.Add(new ColumnWithValue { FromTable = "fpChqHed", ToTable = "fDebtor", FromColumn = "DebCode", ToColumn = "DebCode", JoinType = QJoinType.INNERJOIN, Comparison = QComparison.EQUALS });

            Query query = new Query() { TableName = "fpChqHed", QType = QueryType.SELECT, ColValues = columnList.ToArray(), OrderbyClause = orderList.ToArray(), JoinStructure = joinList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));
        }

         /// <summary>
       /// Get Tax combination codes
       /// </summary>
       /// <returns></returns>
        public DataTable HelpCombCode()   // This table does not exist in the Global db
        {
            // Select combCode,combName From fpolycbgrp ORDER BY CombCode
            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "CombCode" });
            columnList.Add(new ColumnWithValue() { ColumnName = "CombName" });
            List<ColumnWithValue> orderList = new List<ColumnWithValue>();
            orderList.Add(new ColumnWithValue() { ColumnName = "CombCode" });

            Query query = new Query() { TableName = "fpolycbgrp", QType = QueryType.SELECT, ColValues = columnList.ToArray(), OrderbyClause = orderList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));
        }

         /// <summary>
       /// Get consolidated Account details - (before transfer to costcode) 
       /// </summary>
       /// <returns></returns>
        public DataTable HelpConAcc()
        {
            // In this table AccType field contains - p - PNL, B -Balance Sheet , M- MAnufacturing
            // Select AccCode,AccDesc From fConAcc Where Seq1=0 And Seq2=0 ORDER BY AccCode

            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "AccCode" });
            columnList.Add(new ColumnWithValue() { ColumnName = "AccDesc" });
            List<ColumnWithValue> whereList = new List<ColumnWithValue>();
            whereList.Add(new ColumnWithValue() { ColumnName = "Seq1", Comparison = QComparison.EQUALS, ColumnValue = 0, ColumnConnector = QLogicOperator.AND });
            whereList.Add(new ColumnWithValue() { ColumnName = "Seq2", Comparison = QComparison.EQUALS, ColumnValue = 0 });
            
            List<ColumnWithValue> orderList = new List<ColumnWithValue>();
            orderList.Add(new ColumnWithValue() { ColumnName = "AccCode" });
            Query query = new Query() { TableName = "fConAcc", QType = QueryType.SELECT, ColValues = columnList.ToArray(), OrderbyClause = orderList.ToArray(),WhereClause=whereList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));
           
        }

        /// <summary>
       /// Get cost centre details
       /// </summary>
       /// <returns></returns>
        public DataTable HelpCostCentre()
        {
            // Select CostCode,CostName From fCost ORDER BY CostCode
            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "CostCode" });
            columnList.Add(new ColumnWithValue() { ColumnName = "CostName" });

            List<ColumnWithValue> orderList = new List<ColumnWithValue>();
            orderList.Add(new ColumnWithValue() { ColumnName = "CostCode" });
            Query query = new Query() { TableName = "fCost", QType = QueryType.SELECT, ColValues = columnList.ToArray(), OrderbyClause = orderList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));
        }

          /// <summary>
       /// Get Tax Hed details
       /// </summary>
       /// <returns></returns>
        public DataTable HelpTaxHed()
        {
            // Select TaxComCode,TaxComName From fTaxHed Where Active='1' ORDER BY TaxComCode 
            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "TaxComCode" });
            columnList.Add(new ColumnWithValue() { ColumnName = "TaxComName" });

            List<ColumnWithValue> whereList = new List<ColumnWithValue>();
            whereList.Add(new ColumnWithValue() { ColumnName = "Active", Comparison = QComparison.EQUALS, ColumnValue = 1});

            List<ColumnWithValue> orderList = new List<ColumnWithValue>();
            orderList.Add(new ColumnWithValue() { ColumnName = "TaxComCode" });
            Query query = new Query() { TableName = "fTaxHed", QType = QueryType.SELECT, ColValues = columnList.ToArray(), OrderbyClause = orderList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));
        }

        /// <summary>
       /// Get Unit details
       /// </summary>
       /// <returns></returns>
        public DataTable HelpUnit()
        {
            // Select UnitCode,UnitName From fUnit ORDER BY UnitCode 
            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "UnitCode" });
            columnList.Add(new ColumnWithValue() { ColumnName = "UnitName" });

            List<ColumnWithValue> orderList = new List<ColumnWithValue>();
            orderList.Add(new ColumnWithValue() { ColumnName = "UnitCode" });
            Query query = new Query() { TableName = "fUnit", QType = QueryType.SELECT, ColValues = columnList.ToArray(), OrderbyClause = orderList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));
        }

          /// <summary>
       /// Get creditor group details
       /// </summary>
       /// <returns></returns>
        public DataTable HelpCreGrp()
        {
            // Select CrGrCode,CrGrName,AddDate From fCreGrp Order By CrGrCode

            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "CrGrCode" });
            columnList.Add(new ColumnWithValue() { ColumnName = "CrGrName" });
            columnList.Add(new ColumnWithValue() { ColumnName = "AddDate" });

            List<ColumnWithValue> orderList = new List<ColumnWithValue>();
            orderList.Add(new ColumnWithValue() { ColumnName = "CrGrCode" });
            Query query = new Query() { TableName = "fCreGrp", QType = QueryType.SELECT, ColValues = columnList.ToArray(), OrderbyClause = orderList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));
        }

        
       /// <summary>
       /// Get creditor group details
       /// </summary>
       /// <returns></returns>
        public DataTable HelpCurrency()
        {
            // Select CurCode,CurDesc From fCurrency ORDER BY CurCode

            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "CurCode" });
            columnList.Add(new ColumnWithValue() { ColumnName = "CurDesc" });         

            List<ColumnWithValue> orderList = new List<ColumnWithValue>();
            orderList.Add(new ColumnWithValue() { ColumnName = "CurCode" });
            Query query = new Query() { TableName = "fCurrency", QType = QueryType.SELECT, ColValues = columnList.ToArray(), OrderbyClause = orderList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));
        }

        /// <summary>
        /// Get Purchase Accounts
        /// </summary>
        /// <returns></returns>

        public DataTable HelpPurchaseAcc() 
        {
            string query = "Select AccCode,AccDesc From fConAcc INNER JOIN fGlfSc ON fConAcc.AccSortPk=fGlfSc.AccSortPk  " +
                    " Where (fGlfSc.AccTyp=@accType1 or fGlfSc.AccTyp=@accType2) and fConAcc.AccCat=@accountCat1 and fConAcc.ConAcc=@controlAccount";

            var parametersSelectAccounts = new List<Parameter>
                                 {
                                     new Parameter{ParamName="@accountCat1",ParamValue=1},  
                                      new Parameter{ParamName="@accType1",ParamValue="P"}, 
                                      new Parameter{ParamName="@accType2",ParamValue="M"}, 
                                      new Parameter{ParamName="@controlAccount",ParamValue="Y"}                                     
                                 };

            var conAccQuery = new Query() { QueryString = query, QType = QueryType.SELECTOTHER, ParameterList = parametersSelectAccounts .ToArray()};
            return (_databaseAccess.ExcecuteSelect(conAccQuery,true));
        }

        /// <summary>
       /// Get Discount Accounts
       /// </summary>
       /// <returns></returns>

        public DataTable HelpDiscountAcc()
        {
         // "Select AccCode,AccDesc From fConAcc Where ConAcc=@controlAccount";                       

            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "AccCode" });
            columnList.Add(new ColumnWithValue() { ColumnName = "AccDesc" });
            List<ColumnWithValue> whereList = new List<ColumnWithValue>();
            whereList.Add(new ColumnWithValue() { ColumnName = "ConAcc", Comparison = QComparison.EQUALS, ColumnValue = "Y"});

            Query query = new Query() { TableName = "fConAcc", QType = QueryType.SELECT, ColValues = columnList.ToArray(),WhereClause=whereList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));
        }

        /// <summary>
       /// Get Sales Accounts
       /// </summary>
       /// <returns></returns>

        public DataTable HelpSalesAcc()
        {
           //"Select AccCode,AccDesc From fConAcc  Where AccTyp=@accType1 and AccCat=@accountCat1 and ConAcc=@controlAccount";

            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "AccCode" });
            columnList.Add(new ColumnWithValue() { ColumnName = "AccDesc" });
            List<ColumnWithValue> whereList = new List<ColumnWithValue>();
            whereList.Add(new ColumnWithValue() { ColumnName = "AccTyp", Comparison = QComparison.EQUALS, ColumnValue = "P",ColumnConnector=QLogicOperator.AND });
            whereList.Add(new ColumnWithValue() { ColumnName = "AccCat", Comparison = QComparison.EQUALS, ColumnValue = 1, ColumnConnector = QLogicOperator.AND });
            whereList.Add(new ColumnWithValue() { ColumnName = "ConAcc", Comparison = QComparison.EQUALS, ColumnValue ="Y" });

            Query query = new Query() { TableName = "fConAcc", QType = QueryType.SELECT, ColValues = columnList.ToArray(), WhereClause = whereList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));

        }

         /// <summary>
       /// Get customer details
       /// </summary>
       /// <returns></returns>
        public DataTable HelpCustomer()
        {
            // Select DebCode,DebName,debctnam,DebAdd1,DebAdd2,DebAdd3 From fDebtor where status = 'A'
            // ORDER BY DebCode
            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "DebCode"});
            columnList.Add(new ColumnWithValue() { ColumnName = "DebName"});
            columnList.Add(new ColumnWithValue() { ColumnName = "debctnam"});
            columnList.Add(new ColumnWithValue() { ColumnName = "DebAdd1"});
            columnList.Add(new ColumnWithValue() { ColumnName = "DebAdd2"});
            columnList.Add(new ColumnWithValue() { ColumnName = "DebAdd3" });

            List<ColumnWithValue> whereList = new List<ColumnWithValue>();
            whereList.Add(new ColumnWithValue() { ColumnName = "status", Comparison = QComparison.EQUALS, ColumnValue = "A" });

            List<ColumnWithValue> orderList = new List<ColumnWithValue>();
            orderList.Add(new ColumnWithValue { ColumnName = "DebCode" });
            Query query = new Query() { TableName = "fDebtor", QType = QueryType.SELECT, ColValues = columnList.ToArray(), WhereClause = whereList.ToArray(),OrderbyClause =orderList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));

        }

         /// <summary>
       /// Get debtor group details
       /// </summary>
       /// <returns></returns>
        public DataTable HelpDebGrp()
        {
            // Select DbGrCode,DbGrName From fDebGrp ORDER BY DbGrCode
            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "DbGrCode" });
            columnList.Add(new ColumnWithValue() { ColumnName = "DbGrName" });
            List<ColumnWithValue> orderList = new List<ColumnWithValue>();
            orderList.Add(new ColumnWithValue() { ColumnName = "DbGrCode" });

            Query query = new Query() { TableName = "fDebGrp", QType = QueryType.SELECT, ColValues = columnList.ToArray(), OrderbyClause = orderList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));
        }
          /// <summary>
       /// Get department details
       /// </summary>
       /// <returns></returns>
        public DataTable HelpDepartment()
        {
            // Select FDEPTCODE,FDEPTNAME From fDept ORDER BY FDEPTCODE
            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "FDEPTCODE" });
            columnList.Add(new ColumnWithValue() { ColumnName = "FDEPTNAME" });
            List<ColumnWithValue> orderList = new List<ColumnWithValue>();
            orderList.Add(new ColumnWithValue() { ColumnName = "FDEPTCODE" });

            Query query = new Query() { TableName = "fDept", QType = QueryType.SELECT, ColValues = columnList.ToArray(), OrderbyClause = orderList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));
        }

        /// <summary>
       /// Get department policy details
       /// </summary>
       /// <returns></returns>
        public DataTable HelpDepPolicy()
        {
            // Select Policy,PolicyName From ffDepPolicy ORDER BY Policy
            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "Policy" });
            columnList.Add(new ColumnWithValue() { ColumnName = "PolicyName" });
            List<ColumnWithValue> orderList = new List<ColumnWithValue>();
            orderList.Add(new ColumnWithValue() { ColumnName = "Policy" });

            Query query = new Query() { TableName = "ffDepPolicy", QType = QueryType.SELECT, ColValues = columnList.ToArray(), OrderbyClause = orderList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));
        }

         /// <summary>
       /// Get fixed assets details
       /// </summary>
       /// <returns></returns>
        public DataTable HelpfAssets()
        {
            // Select AstCode,AstName From ffAssets ORDER BY AstCOde
            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "AstCode" });
            columnList.Add(new ColumnWithValue() { ColumnName = "AstName" });
            List<ColumnWithValue> orderList = new List<ColumnWithValue>();
            orderList.Add(new ColumnWithValue() { ColumnName = "AstCOde" });

            Query query = new Query() { TableName = "ffAssets", QType = QueryType.SELECT, ColValues = columnList.ToArray(), OrderbyClause = orderList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));
        }

         /// <summary>
       /// Get Brand details
       /// </summary>
       /// <returns></returns>
        public DataTable HelpfBrand()
        {
            // Select BrandCode,BrandName From ffBrand ORDER BY BrandCode
            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "BrandCode" });
            columnList.Add(new ColumnWithValue() { ColumnName = "BrandName" });
            List<ColumnWithValue> orderList = new List<ColumnWithValue>();
            orderList.Add(new ColumnWithValue() { ColumnName = "BrandCode" });

            Query query = new Query() { TableName = "ffBrand", QType = QueryType.SELECT, ColValues = columnList.ToArray(), OrderbyClause = orderList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));
        }

         /// <summary>
       /// Get Category details
       /// </summary>
       /// <returns></returns>
        public DataTable HelpfCategory()
        {
            // Select CatCode,CatName From ffCategory ORDER BY CatCode
            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "CatCode" });
            columnList.Add(new ColumnWithValue() { ColumnName = "CatName" });
            List<ColumnWithValue> orderList = new List<ColumnWithValue>();
            orderList.Add(new ColumnWithValue() { ColumnName = "CatCode" });

            Query query = new Query() { TableName = "ffCategory", QType = QueryType.SELECT, ColValues = columnList.ToArray(), OrderbyClause = orderList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));
        }

        /// <summary>
       /// Get department details
       /// </summary>
       /// <returns></returns>
        public DataTable HelpfDepartment()
        {
            // Select DeptCode,DeptName From ffDepartment ORDER BY DeptCode
            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "DeptCode" });
            columnList.Add(new ColumnWithValue() { ColumnName = "DeptName" });
            List<ColumnWithValue> orderList = new List<ColumnWithValue>();
            orderList.Add(new ColumnWithValue() { ColumnName = "DeptCode" });

            Query query = new Query() { TableName = "ffDepartment", QType = QueryType.SELECT, ColValues = columnList.ToArray(), OrderbyClause = orderList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));
        }

        /// <summary>
       /// Get department details
       /// </summary>
       /// <returns></returns>
        public DataTable HelpfDepMethod()
        {
            // Select Method,MethodName From ffDepMethod ORDER BY Method
            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "Method" });
            columnList.Add(new ColumnWithValue() { ColumnName = "MethodName" });
            List<ColumnWithValue> orderList = new List<ColumnWithValue>();
            orderList.Add(new ColumnWithValue() { ColumnName = "Method" });

            Query query = new Query() { TableName = "ffDepMethod", QType = QueryType.SELECT, ColValues = columnList.ToArray(), OrderbyClause = orderList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));
        }

         
       /// <summary>
       /// Get general accounts details
       /// </summary>
       /// <returns></returns>
        public DataTable HelpfGAcc()
        {
            // Select AccCode,AccDesc From fGlfAcc Where AccTyp='B' ORDER BY AccCode 
            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "AccCode" });
            columnList.Add(new ColumnWithValue() { ColumnName = "AccDesc" });
           
            List<ColumnWithValue> whereList = new List<ColumnWithValue>();
            whereList.Add(new ColumnWithValue() { ColumnName = "AccTyp", Comparison = QComparison.EQUALS, ColumnValue = "B" });

            List<ColumnWithValue> orderList = new List<ColumnWithValue>();
            orderList.Add(new ColumnWithValue { ColumnName = "AccCode" });
            Query query = new Query() { TableName = "fGlfAcc", QType = QueryType.SELECT, ColValues = columnList.ToArray(), WhereClause = whereList.ToArray(), OrderbyClause = orderList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));

        }
         /// <summary>
       /// Get GRN details
       /// </summary>
       /// <returns></returns>
        public DataTable HelpFileNo()
        {
            // "Select DISTINCT a.manuref,a.txndate,a.LocCode,a.supCode,a.CurCode From FGrnhed a,fGrnDet" 
             //   " b where a.RefNo=b.RefNo and b.BalQty >@quantity Order By manuRef Desc ";

            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "FGrnhed.manuref" });
            columnList.Add(new ColumnWithValue() { ColumnName = "FGrnhed.txndate" });
            columnList.Add(new ColumnWithValue() { ColumnName = "FGrnhed.LocCode" });
            columnList.Add(new ColumnWithValue() { ColumnName = "FGrnhed.supCode" });
            columnList.Add(new ColumnWithValue() { ColumnName = "FGrnhed.CurCode" });
            

            List<ColumnWithValue> whereList = new List<ColumnWithValue>();
            whereList.Add(new ColumnWithValue() { ColumnName = "fGrnDet.BalQty", Comparison = QComparison.GREATERTHAN, ColumnValue = 0.00 });

            List<ColumnWithValue> orderList = new List<ColumnWithValue>();
            orderList.Add(new ColumnWithValue { ColumnName = "FGrnhed.manuRef" ,OrderBy=QOrderby.DESCENDING });

            List<ColumnWithValue> joinList = new List<ColumnWithValue>();
            joinList.Add(new ColumnWithValue { FromTable = "FGrnhed", ToTable = "fGrnDet", FromColumn = "RefNo", ToColumn = "RefNo", JoinType = QJoinType.INNERJOIN, Comparison = QComparison.EQUALS });


            Query query = new Query() { TableName = "FGrnhed", QType = QueryType.SELECTDISTINCT, ColValues = columnList.ToArray(), WhereClause = whereList.ToArray(), OrderbyClause = orderList.ToArray(),JoinStructure=joinList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));
        }

        /// <summary>
        /// Get Fixed assets items details
        /// </summary>
        /// <returns></returns>
        public DataTable HelpffItems()
        {
            // Select fItemCode,fItemName From ffItems ORDER BY fItemCOde 
            List<ColumnWithValue> columnList = new List<ColumnWithValue>();
            columnList.Add(new ColumnWithValue() { ColumnName = "fItemCode" });
            columnList.Add(new ColumnWithValue() { ColumnName = "fItemName" });
            List<ColumnWithValue> orderList = new List<ColumnWithValue>();
            orderList.Add(new ColumnWithValue() { ColumnName = "fItemCOde" });

            Query query = new Query() { TableName = "ffItems", QType = QueryType.SELECT, ColValues = columnList.ToArray(), OrderbyClause = orderList.ToArray() };
            return (_databaseAccess.ExcecuteSelect(query));
        }

        /// <summary>
       /// Get Fixed assets location details
       /// </summary>
       /// <returns></returns>
       public DataTable HelpffLocation()
       {
           // Select LocCode,LocName From ffLocation ORDER BY LocCode 
           List<ColumnWithValue> columnList = new List<ColumnWithValue>();
           columnList.Add(new ColumnWithValue() { ColumnName = "LocCode" });
           columnList.Add(new ColumnWithValue() { ColumnName = "LocName" });
           List<ColumnWithValue> orderList = new List<ColumnWithValue>();
           orderList.Add(new ColumnWithValue() { ColumnName = "LocCode" });

           Query query = new Query() { TableName = "ffLocation", QType = QueryType.SELECT, ColValues = columnList.ToArray(), OrderbyClause = orderList.ToArray() };
           return (_databaseAccess.ExcecuteSelect(query));
       }

       /// <summary>
       /// Get Fixed assets sub category
       /// </summary>
       /// <returns></returns>
       public DataTable HelpffSCategory()
       {
           // Select SCatCode,SCatName From ffSCategory ORDER BY SCatCode 
           List<ColumnWithValue> columnList = new List<ColumnWithValue>();
           columnList.Add(new ColumnWithValue() { ColumnName = "SCatCode" });
           columnList.Add(new ColumnWithValue() { ColumnName = "SCatName" });
           List<ColumnWithValue> orderList = new List<ColumnWithValue>();
           orderList.Add(new ColumnWithValue() { ColumnName = "SCatCode" });

           Query query = new Query() { TableName = "ffSCategory", QType = QueryType.SELECT, ColValues = columnList.ToArray(), OrderbyClause = orderList.ToArray() };
           return (_databaseAccess.ExcecuteSelect(query));
         
       }

       /// <summary>
       /// Get Fixed assets sub location
       /// </summary>
       /// <returns></returns>
       public DataTable HelpffSlocation()
       {
           // Select SLocCode,SLocName From ffSlocation ORDER BY SLocCode

           List<ColumnWithValue> columnList = new List<ColumnWithValue>();
           columnList.Add(new ColumnWithValue() { ColumnName = "SLocCode" });
           columnList.Add(new ColumnWithValue() { ColumnName = "SLocName" });
           List<ColumnWithValue> orderList = new List<ColumnWithValue>();
           orderList.Add(new ColumnWithValue() { ColumnName = "SLocCode" });

           Query query = new Query() { TableName = "ffSlocation", QType = QueryType.SELECT, ColValues = columnList.ToArray(), OrderbyClause = orderList.ToArray() };
           return (_databaseAccess.ExcecuteSelect(query));
       }

        /// <summary>
       /// Get GL finanacial year
       /// </summary>
       /// <returns></returns>
       public DataTable HelpGLfYea()
       {
           // Select Refno,AccFrom,AccTo From fGlfYea Order By Refno Desc
           List<ColumnWithValue> columnList = new List<ColumnWithValue>();
           columnList.Add(new ColumnWithValue() { ColumnName = "Refno" });
           columnList.Add(new ColumnWithValue() { ColumnName = "AccFrom" });
           columnList.Add(new ColumnWithValue() { ColumnName = "AccTo" });
           List<ColumnWithValue> orderList = new List<ColumnWithValue>();
           orderList.Add(new ColumnWithValue() { ColumnName = "Refno" ,OrderBy=QOrderby.DESCENDING});

           Query query = new Query() { TableName = "fGlfYea", QType = QueryType.SELECT, ColValues = columnList.ToArray(), OrderbyClause = orderList.ToArray() };
           return (_databaseAccess.ExcecuteSelect(query));
       }

         /// <summary>
       /// Get Tax details
       /// </summary>
       /// <returns></returns>
       public DataTable HelpTaxCode()
       {
           // Select TaxCode,TaxName,TaxPer From fTax ORDER BY TaxCode
           List<ColumnWithValue> columnList = new List<ColumnWithValue>();
           columnList.Add(new ColumnWithValue() { ColumnName = "TaxPk" });
           columnList.Add(new ColumnWithValue() { ColumnName = "TaxCode" });
           columnList.Add(new ColumnWithValue() { ColumnName = "TaxName" });
           columnList.Add(new ColumnWithValue() { ColumnName = "TaxPer" });
           List<ColumnWithValue> orderList = new List<ColumnWithValue>();
           orderList.Add(new ColumnWithValue() { ColumnName = "TaxCode" });

           Query query = new Query() { TableName = "fTax", QType = QueryType.SELECT, ColValues = columnList.ToArray(), OrderbyClause = orderList.ToArray() };
           return (_databaseAccess.ExcecuteSelect(query));
       }

         /// <summary>
       /// Get GRN Hed details
       /// </summary>
       /// <returns></returns>
       public DataTable HelpGRNHed()
       {
           // Thushari:This need to be checked for Distinct.
           // Select DISTINCT a.Refno,a.txndate,a.LocCode,a.supCode,a.CurCode,CostCode From FGrnhed a,
           // fGrnDet b where a.RefNo=b.RefNo and b.BalQty >0.00 Order By Refno Desc

           List<ColumnWithValue> columnList = new List<ColumnWithValue>();
           columnList.Add(new ColumnWithValue() { ColumnName = "FGrnhed.manuref" });
           columnList.Add(new ColumnWithValue() { ColumnName = "FGrnhed.txndate" });
           columnList.Add(new ColumnWithValue() { ColumnName = "FGrnhed.LocCode" });
           columnList.Add(new ColumnWithValue() { ColumnName = "FGrnhed.supCode" });
           columnList.Add(new ColumnWithValue() { ColumnName = "FGrnhed.CurCode" });

           List<ColumnWithValue> whereList = new List<ColumnWithValue>();
           whereList.Add(new ColumnWithValue() { ColumnName = "fGrnDet.BalQty", Comparison = QComparison.GREATERTHAN, ColumnValue = 0.00 });

           List<ColumnWithValue> orderList = new List<ColumnWithValue>();
           orderList.Add(new ColumnWithValue { ColumnName = "FGrnhed.manuRef", OrderBy = QOrderby.DESCENDING });

           List<ColumnWithValue> joinList = new List<ColumnWithValue>();
           joinList.Add(new ColumnWithValue { FromTable = "FGrnhed", ToTable = "fGrnDet", FromColumn = "RefNo", ToColumn = "RefNo", JoinType = QJoinType.INNERJOIN, Comparison = QComparison.EQUALS });
           
           Query query = new Query() { TableName = "FGrnhed", QType = QueryType.SELECTDISTINCT, ColValues = columnList.ToArray(), WhereClause = whereList.ToArray(), OrderbyClause = orderList.ToArray(), JoinStructure = joinList.ToArray() };
           return (_databaseAccess.ExcecuteSelect(query));
       }

       /// <summary>
       /// Get GRN Return Stock details
       /// </summary>
       /// <returns></returns>
       public DataTable HelpGRNRStk()
       {
           // SELECT LocCode, ItemCode, BalQty,TxnDate, CostPrice, RefNo, StkRecNo From fStkIn Order By RefNo Desc
           List<ColumnWithValue> columnList = new List<ColumnWithValue>();
           columnList.Add(new ColumnWithValue() { ColumnName = "LocCode" });
           columnList.Add(new ColumnWithValue() { ColumnName = "ItemCode" });
           columnList.Add(new ColumnWithValue() { ColumnName = "BalQty" });
           columnList.Add(new ColumnWithValue() { ColumnName = "TxnDate" });
           columnList.Add(new ColumnWithValue() { ColumnName = "CostPrice" });
           columnList.Add(new ColumnWithValue() { ColumnName = "RefNo" });
           columnList.Add(new ColumnWithValue() { ColumnName = "StkRecNo" });

           List<ColumnWithValue> orderList = new List<ColumnWithValue>();
           orderList.Add(new ColumnWithValue() { ColumnName = "RefNo", OrderBy = QOrderby.DESCENDING });

           Query query = new Query() { TableName = "fStkIn", QType = QueryType.SELECT, ColValues = columnList.ToArray(), OrderbyClause = orderList.ToArray() };
           return (_databaseAccess.ExcecuteSelect(query));
       }

    }

   
}
